#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <iostream>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>

using namespace std;

int main()
{
    //将管道以读的方式打开
    int input = open("./practice", O_RDONLY);
    if (input == -1)
    {
        perror("open fail");
        return 1;
    }

    char buf[1024];
    int ret_r;

    sleep(7);

    while((ret_r = read(input, buf, sizeof(buf))))
    {
        cout << buf << endl;
    }

    close(input);

    return 0;
}
